﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using WebApiDemo.Models;

namespace BaseReport.SQL
{
    public class BaseSql
    {
        public List<Person> GetUsers()
        {
            string conStr = "Server=qds114575410.my3w.com;Database=qds114575410_db;user id=qds114575410;password=Ss6785220;connect Timeout=20";
            SqlConnection con = new SqlConnection(conStr);
            string sqlStr = " SELECT * FROM Person";
            SqlDataAdapter da = new SqlDataAdapter(sqlStr, con);
            DataSet ds=new DataSet();
            da.Fill(ds);

            var result=new List<Person>();
            var obj = new Person();
            if (ds.Tables.Count>0)
            {
                var dt = ds.Tables[0];
                foreach (DataRow item in dt.Rows)
                {
                    obj=new Person();
                    obj.Id = item["PersonNo"].ToString();
                    obj.Name = item["Name"].ToString();
                    obj.Msg = item["Adress"].ToString();
                    result.Add(obj);
                }
            }
            return result;
        }
    }
}
